
/**
 * 链接多个对象
 */
class BridgeClass {
  constructor(...args) {
    console.log('初始化并链接各对象。。。')
    this.classOne = new ClassOne(...args)
    this.classTwo = new ClassTwo(...args)
  }
}

class ClassOne {
  consturctor(...args) {
    console.log(this.name)   
  }
}

class ClassTwo {
  consturctor(...args) {
    console.log(this.name)   
  }
}

const bridge = new BridgeClass()

console.log(bridge.classOne)
console.log(bridge.classTwo)


/**
 * 屏蔽接口调用
 */

class Interface {}

Interface.prototype.callApi = () => {
  console.log('it is interface...')
}

class ApiOne extends Interface {
  constructor(...args) {
    super()
    console.log(this)   
  }

  callApi() {
    console.log('it is ApiOne')  
  }

}

class ApiTwo extends Interface {
  constructor(...args) {
    super()
    console.log(this)  
  }

  callApi() {
    console.log('it is ApiTwo')
  }

}

class BridgePattern {
  constructor(...args) {
    this.bridgeArray = new Array()
    
    this.bridgeArray.push(new ApiOne())
    this.bridgeArray.push(new ApiTwo())
  }
}

const bridgePattern = new BridgePattern()
bridgePattern.bridgeArray[0].callApi()
bridgePattern.bridgeArray[1].callApi()
